//
//  RPViewController.m
//  RPSlidingMenuDemo
//
//  Created by Paul Thorsteinson on 2/24/2014.
//  Copyright (c) 2014 Robots and Pencils Inc. All rights reserved.
//

#import "RPViewController.h"
#import "Unit.h"
#import "PHAirViewController.h"

@interface RPViewController ()
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;

@end

@implementation RPViewController


- (void)leftButtonTouch
{
    [self.airViewController showAirViewFromViewController:self.navigationController complete:nil];
}


- (void)viewDidLoad{
    [super viewDidLoad];

    // Example of changing the feature height and collapsed height for all
    //self.featureHeight = 200.0f;
    //self.collapsedHeight = 100.0f;
    
    [self.navigationController setNavigationBarHidden:NO];

    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 44, 44);

//    button.backgroundColor = [UIColor colorWithPatternImage:];
    [button setImage:[UIImage imageNamed:@"左上角-图标"] forState: UIControlStateNormal];
    [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(leftButtonTouch) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    
    
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:250/255.0 green:250/255.0 blue:250/255.0 alpha:1]];
    [[UINavigationBar appearance] setTranslucent:NO];
    
    [[UINavigationBar appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor colorWithRed:92/255.0 green:91/255.0 blue:91/255.0 alpha:1],
      UITextAttributeTextColor,
      [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],
      UITextAttributeTextShadowColor,
      //      [NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
      //      UITextAttributeTextShadowOffset,
      [UIFont fontWithName:@"Arial-Bold" size:0.0],
      UITextAttributeFont,
      nil]];
    self.title = @"酷拉丁精选";
    
    typeof(self) bself = self;
    self.phSwipeHander = ^{
        [bself.airViewController showAirViewFromViewController:bself.navigationController complete:nil];
    };
    


}


#pragma mark - RPSlidingMenuViewController


-(NSInteger)numberOfItemsInSlidingMenu{
    // 10 for demo purposes, typically the count of some array
    return 4;
}

- (void)customizeCell:(RPSlidingMenuCell *)slidingMenuCell forRow:(NSInteger)row{
 
    // alternate for demo.  Simply set the properties of the passed in cell

    if ( row == 0) {
        slidingMenuCell.textLabel.text = @"";
        slidingMenuCell.detailTextLabel.text = @"";
        slidingMenuCell.backgroundImageView.image = [UIImage imageNamed:@"tu-0-"];
    }else if ( row == 1) {
        slidingMenuCell.textLabel.text = @"";
        slidingMenuCell.detailTextLabel.text = @"";
        slidingMenuCell.backgroundImageView.image = [UIImage imageNamed:@"tu-1-"];

    }
    else if ( row == 2) {
        slidingMenuCell.textLabel.text = @"";
        slidingMenuCell.detailTextLabel.text = @"";
        slidingMenuCell.backgroundImageView.image = [UIImage imageNamed:@"tu-2-"];
    }
    else if ( row == 3) {
        slidingMenuCell.textLabel.text = @"";
        slidingMenuCell.detailTextLabel.text = @"";
        slidingMenuCell.backgroundImageView.image = [UIImage imageNamed:@"tu-3-"];
    }
    
}

- (void)slidingMenu:(RPSlidingMenuViewController *)slidingMenu didSelectItemAtRow:(NSInteger)row{

    [super slidingMenu:slidingMenu didSelectItemAtRow:row];

    // when a row is tapped do some action
//    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Row Tapped"
//                                                    message:[NSString stringWithFormat:@"Row %ld tapped.", (long)row]
//                                                   delegate:nil
//                                          cancelButtonTitle:@"OK"
//                                          otherButtonTitles: nil];
//    [alert show];
}


@end
